package com.atguigu.mediator.smartHouse;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description: 同事 - 抽象类
 * @create: 2022-03-09 10:34
 **/
public abstract class Colleague {
    private Mediator mediator;
    public String name;

    /**
     * 在创建同事类对象的时候，就直接通过构造器，加入到 ConcreteMediator 的 colleagueMap 中
     * @param mediator 中介者类，用来收集各个同事类，并集中处理同事类的逻辑
     * @param name 同事类的名称
     */
    public Colleague(Mediator mediator, String name) {
        this.mediator = mediator;
        this.name = name;
        mediator.register(name, this);
    }

    public Mediator getMediator(){
        return this.mediator;
    }

    /**
     *
     * @param stateChange
     */
    public abstract void sendMessage(int stateChange);

}
